// ----------------------------------------------------------------------------------
// Microsoft Developer & Platform Evangelism
// 
// Copyright (c) Microsoft Corporation. All rights reserved.
// 
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES 
// OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// ----------------------------------------------------------------------------------
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
// ----------------------------------------------------------------------------------

namespace Riolinx.SocialConnekt.Library.Protocols
{
    using System;
    using System.Web;

    using Microsoft.IdentityModel.Claims;

    using Riolinx.SocialConnekt.Library.Configuration;
    using Riolinx.SocialConnekt.Library.Model;

    public abstract class ProtocolHandlerBase : IProtocolHandler
    {
        protected ProtocolHandlerBase(ClaimProvider issuer) : this(issuer, new DefaultConfigurationRepository())
        {
        }
        
        protected ProtocolHandlerBase(ClaimProvider issuer, IConfigurationRepository configuration)
        {
            if (issuer == null)
                throw new ArgumentNullException("issuer");

            if (configuration == null)
                throw new ArgumentNullException("configuration");

            this.Issuer = issuer;
            this.Configuration = configuration;
            this.MultiProtocolIssuer = this.Configuration.RetrieveMultiProtocolIssuer();              
        }

        protected ClaimProvider Issuer { get; set; }

        protected IConfigurationRepository Configuration { get; set; }

        protected MultiProtocolIssuer MultiProtocolIssuer { get; set; }

        public abstract void ProcessSignInRequest(Scope scope, HttpContextBase httpContext);

        public abstract IClaimsIdentity ProcessSignInResponse(string realm, string originalUrl, HttpContextBase httpContext);        
    }
}